package com.mew.chess.core.game.pokdeng.game.message;

import cn.hutool.core.util.RandomUtil;
import com.mew.chess.core.game.bjl.game.common.BjlConstantValue;
import com.mew.common.config.NicknameUtil;
import com.mew.common.enm.UserType;
import com.mew.common.util.NumberUtil;
import com.mew.common.util.RandomIdUtil;
import com.mew.common.vo.UserSessionVO;
import com.zebra.common.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Data
@ToString
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserMessage extends UserSessionVO {

    //剔除限制金币
    private long kickGold;

    private long  bet;
    private long payment;
    private int tax;

    private List<Integer> cards=new ArrayList();
    private int cardType;
    private int cardVal;
    private int cardRate=1;

    @Override
    public void write(ByteBuf b) {
        //TODO 只发送brnn 需要的用户信息
        super.write(b);
        ByteBufUtils.writeLong(b,bet);
        ByteBufUtils.writeLong(b,payment);

        ByteBufUtils.writeInt(b,cards.size());
        for (Integer card : cards) {
            ByteBufUtils.writeInt(b,card);
        }
        ByteBufUtils.writeInt(b,cardType);
        ByteBufUtils.writeInt(b,cardVal);
        ByteBufUtils.writeInt(b,cardRate);
    }

    public void bet(long betNumber){
        this.bet = betNumber;
        updateGoldNumber(-betNumber);
    }

    public void clear(){
        this.bet=0;
        this.payment=0;
        this.cardType=0;
        this.cardVal=0;
        this.cardRate=1;
        this.cards.clear();
    }
}